package com.heima.article.es;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.util.Date;

/**
 * <p>
 * 文章信息表，存储已发布的文章
 * </p>
 *
 * @author mcm
 * @since 2021-12-16
 */
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(description = "文章信息表，存储已发布的文章")
@Document(indexName = "ap_article_info", type = "_doc", shards = 1, replicas = 0)
public class ApArticleSearch implements Serializable {

    private static final long serialVersionUID = 1L;

    @JsonSerialize(using = ToStringSerializer.class)
    @Id
    private Long id;

    /**
     * 标题
     */
    @Field(type = FieldType.Text,analyzer = "ik_max_word")
    private String title;

    /**
     * 文章作者的ID
     */
    @ApiModelProperty(value = "文章作者的ID")
    @Field(type = FieldType.Integer)
    private Integer authorId;

    /**
     * 作者昵称
     */
    @ApiModelProperty(value = "作者昵称")
    @Field(type = FieldType.Keyword)
    private String authorName;

    /**
     * 文章所属频道ID
     */
    @ApiModelProperty(value = "文章所属频道ID")
    @Field(type = FieldType.Integer)
    private Integer channelId;

    /**
     * 频道名称
     */
    @ApiModelProperty(value = "频道名称")
    @Field(type = FieldType.Keyword)
    private String channelName;

    /**
     * 文章布局
     * 0 无图文章
     * 1 单图文章
     * 2 多图文章
     */
    @ApiModelProperty(value = "文章布局            0 无图文章            1 单图文章            2 多图文章")
    @Field(type = FieldType.Integer)
    private Integer layout;


    /**
     * 文章图片
     * 多张逗号分隔
     */
    @ApiModelProperty(value = "文章图片            多张逗号分隔")
    @Field(type = FieldType.Keyword,index = false)
    private String images;


    /**
     * 创建时间
     */
    @ApiModelProperty(value = "创建时间")
    @Field(type = FieldType.Date)
    private Date createdTime;

    /**
     * 发布时间
     */
    @ApiModelProperty(value = "发布时间")
    @Field(type = FieldType.Date)
    private Date publishTime;


    /**
     * 是否可转发
     */
    @ApiModelProperty(value = "是否可转发")
    @Field(type = FieldType.Boolean)
    private Boolean isForward;

    /**
     * 是否下架
     */
    @ApiModelProperty(value = "是否下架")
    @Field(type = FieldType.Boolean)
    private Boolean isDown;

    /**
     * 是否已删除
     */
    @ApiModelProperty(value = "是否已删除")
    @Field(type = FieldType.Boolean)
    private Boolean isDelete;

    /**
     * 静态页面地址
     */
    @ApiModelProperty(value = "静态页面地址")
    @Field(type = FieldType.Keyword,index = false)
    private String staticUrl;


}
